package org.jugile.demo.domain;

import org.jugile.util.Jugile;

public class Main extends Jugile {

	public static void main(String args[]) throws Exception {
		
		// load domain
		Domain d = Domain.getDomain();
		for (Author a : d.getAuthors()) {
			for (Book b : a.getMainBooks()) {
				print(a.getName() + " " + b.getTitle());
			}
		}
	
		d.createBook().setTitle("hello");
		d.commit();
		for (Book b : d.getBooks()) {
			print("book: " + b.getTitle());
		}

		BookCollection bc = new BookCollection().byTitle("hello");
		for (Book b : bc.fromDb()) {
			print("from db: " + b.getTitle());
			b.archive();
		}
		
		bc = new BookCollection();
		for (Book b : bc.fromDb("where title_f like 'hel%'")) {
			print("sql: " + b.getTitle() + " " + b.getId());
		}
	}
	
}
